from sqlalchemy import Column, BigInteger, Integer, String, DateTime
from sqlalchemy.ext.declarative import declarative_base
from datetime import datetime

Base = declarative_base()

class CmUserVip(Base):
    __tablename__ = 'cm_user_vip'
    id = Column(BigInteger, primary_key=True, autoincrement=True, comment='id')
    user_id = Column(BigInteger, nullable=False, comment='用户id')
    vip_level = Column(Integer, default=0, comment='vip等级')
    start_at = Column(BigInteger, nullable=False, comment='创建时间')
    expire_at = Column(BigInteger, nullable=False, comment='过期时间')

class CmUserOrder(Base):
    __tablename__ = 'cm_user_order'
    id = Column(BigInteger, primary_key=True, autoincrement=True, comment='id')
    user_id = Column(BigInteger, nullable=False, comment='用户id')
    product_id = Column(Integer, nullable=False, comment='产品id')
    third_id = Column(String(200), comment='第三方订单id')
    money = Column(Integer, nullable=False, comment='金额 单位分')
    order_reason = Column(String(500), comment='失败原因')
    order_status = Column(Integer, nullable=False, comment='订单状态 1 创建 2 成功 3 失败 4 退款')
    create_at = Column(BigInteger, nullable=False, comment='创建时间')

class CmUserProduct(Base):
    __tablename__ = 'cm_user_product'
    id = Column(BigInteger, primary_key=True, autoincrement=True, comment='id')
    product_name = Column(String(100), nullable=False, comment='产品名称')
    product_type = Column(Integer, nullable=False, comment='产品类型')
    product_frequency = Column(Integer, default=0, comment='次数')
    product_vip_level = Column(Integer, default=0, comment='vip等级')
    product_original_price = Column(Integer, nullable=False, comment='产品原价')
    product_price = Column(Integer, nullable=False, comment='产品价格')
    product_description = Column(String(500), comment='产品描述')
    product_status = Column(Integer, nullable=False, comment='产品状态')
    product_create_at = Column(BigInteger, nullable=False, comment='创建时间')
    product_update_at = Column(BigInteger, nullable=False, comment='更新时间')

class CmUserFrequency(Base):
    __tablename__ = 'cm_user_frequency'
    id = Column(BigInteger, primary_key=True, autoincrement=True, comment='id')
    user_id = Column(BigInteger, nullable=False, comment='用户id')
    free_frequency = Column(Integer, default=0, comment='免费次数')
    restricted_frequency = Column(Integer, default=0, comment='受限次数')
    permanent_frequency = Column(Integer, default=0, comment='永久次数') 